﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GraphQLSample.Domain.Core;

namespace GraphQLSample.Domain.Services
{
    public class RoleService
        : IRoleService
    {
        private List<Role> _roles;
        public RoleService()
        {
            _roles = new List<Role>();
            for (int i = 0; i < 5; i++)
            {
                _roles.Add(new Role()
                {
                    Id=(i+1).ToString(),
                    Name = Guid.NewGuid().ToString("N"),
                });
            }
        }
        public async Task<IEnumerable<Role>> GetAsync()
        {
            return await Task.FromResult(_roles);
        }

        public Task<Role> GetByIdAsync(string id)
        {
            return Task.FromResult(_roles.SingleOrDefault(u => u.Id.Equals(id)));
        }
    }
}
